//
//  OrderDetailProductCell.m
//  ChineseCollegeStudentsNetwork
//
//  Created by Zheng on 2019/3/23.
//  Copyright © 2019 刘喆. All rights reserved.
//

#import "OrderDetailProductCell.h"



@implementation OrderDetailProductCell {
    UIImageView *proImgv;
    UILabel *titleLbl;
    UILabel *numLbl;
    UILabel *priceTitleLbl;
    UILabel *priceLbl;
}

- (void)setModel:(OrderListModel *)model {
    _model = model;
    
    [proImgv sd_setImageWithURL:[NSURL URLWithString:_model.imageUrl] placeholderImage:[UIImage imageNamed:@"飞艇"]];
    titleLbl.text = _model.productName;
    numLbl.text = [NSString stringWithFormat:@"x%@",_model.count];
    priceLbl.text = [NSString stringWithFormat:@"¥%@",_model.fee];
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        proImgv = [[UIImageView alloc] init];
        [self.contentView addSubview:proImgv];
        [proImgv mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(60);
            make.height.mas_equalTo(80);
            make.left.mas_equalTo(15);
            make.centerY.equalTo(self);
        }];
        
        titleLbl = [[UILabel alloc] init];
        [self.contentView addSubview:titleLbl];
        [titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(proImgv.mas_right).offset(10);
            make.right.mas_equalTo(-20);
            make.top.equalTo(proImgv).offset(3);
        }];
        
        numLbl = [[UILabel alloc] init];
        [self.contentView addSubview:numLbl];
        [numLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(proImgv.mas_right).offset(10);
            make.bottom.equalTo(proImgv).offset(-3);
        }];
        
        priceLbl = [[UILabel alloc] init];
        priceLbl.textColor = UIColorFromRGBHex(0xfa7a09);
        [self.contentView addSubview:priceLbl];
        [priceLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15);
            make.centerY.equalTo(numLbl);
        }];
        
        priceTitleLbl = [[UILabel alloc] init];
        priceTitleLbl.text = @"价格：";
        [self.contentView addSubview:priceTitleLbl];
        [priceTitleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(priceLbl.mas_left);
            make.centerY.equalTo(numLbl);
        }];
        
    }
    return self;
}

@end
